﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using Streambolics.Gui;

namespace Streambolics.Hp41s.Gui
{
    /// <summary>
    ///     A user control that displays the operand stack
    ///     of the attached execution engine.
    /// </summary>

    public partial class StackDisplay : EngineUserControl
    {
        public StackDisplay ()
        {
            InitializeComponent ();
            InterceptDragDrop (label_X);
            InterceptDragDrop (label_Y);
            InterceptDragDrop (label_Z);
            InterceptDragDrop (label_T);
        }

        protected override void OnDisplayChanged (EventArgs e)
        {
            base.OnDisplayChanged (e);
            if (Machine != null)
            {
                label_X.Text = "X: " + Machine.Present (Machine.Registers.X);
                label_Y.Text = "Y: " + Machine.Present (Machine.Registers.Y);
                label_Z.Text = "Z: " + Machine.Present (Machine.Registers.Z);
                label_T.Text = "T: " + Machine.Present (Machine.Registers.T);
            }
            else
            {
                label_X.Text = "X: ";
                label_Y.Text = "Y: ";
                label_Z.Text = "Z: ";
                label_T.Text = "T: ";
            }
        }

        protected override void OnDragStart (DragStartEventArgs e)
        {
            base.OnDragStart (e);
            if (Machine != null)
            {
                e.DragObject = new DragData (Machine.Registers, this);
            }
        }
    }
}
